package com.xiaobai.zhuangxiuguanjia.activities;

import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.ProgressBar;

import com.xiaobai.zhuangxiuguanjia.R;

public class ServiceDocActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_service_doc);

        ActionBar actionBar = getSupportActionBar();
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setTitle("服务条款");

        final ProgressBar serviceDocProgress = (ProgressBar) findViewById(R.id.service_doc_progress);
        serviceDocProgress.setMax(100);

        WebView serviceDocWeb = (WebView) findViewById(R.id.service_doc_webview);
        serviceDocWeb.setWebChromeClient(new WebChromeClient() {
            @Override
            public void onProgressChanged(WebView view, int newProgress) {
                if (newProgress == 100)
                    serviceDocProgress.setVisibility(View.GONE);
                else {
                    if (serviceDocProgress.getVisibility() == View.GONE)
                        serviceDocProgress.setVisibility(View.VISIBLE);

                    serviceDocProgress.setProgress(newProgress);
                }

                super.onProgressChanged(view, newProgress);
            }
        });
        WebSettings settings = serviceDocWeb.getSettings();
        settings.setJavaScriptEnabled(true);
        settings.setCacheMode(WebSettings.LOAD_NO_CACHE);
        settings.setUseWideViewPort(true);
        settings.setLoadWithOverviewMode(true);
        serviceDocWeb.loadUrl("http://mobileapi.to8to.com/smallapp.php?module=h5&action=serviceitem&version=2.5&to8to_from=%E5%BA%94%E7%94%A8%E5%AE%9D&uid=null&channel=%E5%BA%94%E7%94%A8%E5%AE%9D&appversion=2.5.1&systemversion=16&to8to_token=3405491_5355150ca1fbbb7dbdce4f6cff37eea7&appostype=1");
    }
}
